<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python documentation Index' />
<link rel="first" href="lib.html" title='Python library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="dom-nodelist-objects.html" />
<link rel="prev" href="dom-implementation-objects.html" />
<link rel="parent" href="node217.html" />
<link rel="next" href="dom-nodelist-objects.html" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>8.6.2.2 Node Objects </title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="8.6.2.1 domimplementation Objects"
  href="dom-implementation-objects.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="8.6.2 objects in the"
  href="node217.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="8.6.2.3 nodelist Objects"
  href="dom-nodelist-objects.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="dom-implementation-objects.html">8.6.2.1 DOMImplementation Objects</a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="node217.html">8.6.2 Objects in the</a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="dom-nodelist-objects.html">8.6.2.3 NodeList Objects</a>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->

<h3><a name="SECTION0010622000000000000000"></a><a name="dom-node-objects"></a>
<br>
8.6.2.2 Node Objects 
</h3>

<p>
All of the components of an XML document are subclasses of
<tt class="class">Node</tt>.

<p>
<dl><dt><b><tt id='l2h-1775' xml:id='l2h-1775' class="member">nodeType</tt></b></dt>
<dd>
An integer representing the node type.  Symbolic constants for the
types are on the <tt class="class">Node</tt> object:
<tt class="constant">ELEMENT_NODE</tt>, <tt class="constant">ATTRIBUTE_NODE</tt>,
<tt class="constant">TEXT_NODE</tt>, <tt class="constant">CDATA_SECTION_NODE</tt>,
<tt class="constant">ENTITY_NODE</tt>, <tt class="constant">PROCESSING_INSTRUCTION_NODE</tt>,
<tt class="constant">COMMENT_NODE</tt>, <tt class="constant">DOCUMENT_NODE</tt>,
<tt class="constant">DOCUMENT_TYPE_NODE</tt>, <tt class="constant">NOTATION_NODE</tt>.
This is a read-only attribute.
</dl>

<p>
<dl><dt><b><tt id='l2h-1776' xml:id='l2h-1776' class="member">parentNode</tt></b></dt>
<dd>
The parent of the current node, or <code>None</code> for the document node.
The value is always a <tt class="class">Node</tt> object or <code>None</code>.  For
<tt class="class">Element</tt> nodes, this will be the parent element, except for the
root element, in which case it will be the <tt class="class">Document</tt> object.
For <tt class="class">Attr</tt> nodes, this is always <code>None</code>.
This is a read-only attribute.
</dl>

<p>
<dl><dt><b><tt id='l2h-1777' xml:id='l2h-1777' class="member">attributes</tt></b></dt>
<dd>
A <tt class="class">NamedNodeMap</tt> of attribute objects.  Only elements have
actual values for this; others provide <code>None</code> for this attribute.
This is a read-only attribute.
</dl>

<p>
<dl><dt><b><tt id='l2h-1778' xml:id='l2h-1778' class="member">previousSibling</tt></b></dt>
<dd>
The node that immediately precedes this one with the same parent.  For
instance the element with an end-tag that comes just before the
<var>self</var> element's start-tag.  Of course, XML documents are made
up of more than just elements so the previous sibling could be text, a
comment, or something else.  If this node is the first child of the
parent, this attribute will be <code>None</code>.
This is a read-only attribute.
</dl>

<p>
<dl><dt><b><tt id='l2h-1779' xml:id='l2h-1779' class="member">nextSibling</tt></b></dt>
<dd>
The node that immediately follows this one with the same parent.  See
also <tt class="member">previousSibling</tt>.  If this is the last child of the
parent, this attribute will be <code>None</code>.
This is a read-only attribute.
</dl>

<p>
<dl><dt><b><tt id='l2h-1780' xml:id='l2h-1780' class="member">childNodes</tt></b></dt>
<dd>
A list of nodes contained within this node.
This is a read-only attribute.
</dl>

<p>
<dl><dt><b><tt id='l2h-1781' xml:id='l2h-1781' class="member">firstChild</tt></b></dt>
<dd>
The first child of the node, if there are any, or <code>None</code>.
This is a read-only attribute.
</dl>

<p>
<dl><dt><b><tt id='l2h-1782' xml:id='l2h-1782' class="member">lastChild</tt></b></dt>
<dd>
The last child of the node, if there are any, or <code>None</code>.
This is a read-only attribute.
</dl>

<p>
<dl><dt><b><tt id='l2h-1783' xml:id='l2h-1783' class="member">localName</tt></b></dt>
<dd>
The part of the <tt class="member">tagName</tt> following the colon if there is one,
else the entire <tt class="member">tagName</tt>.  The value is a string.
</dl>

<p>
<dl><dt><b><tt id='l2h-1784' xml:id='l2h-1784' class="member">prefix</tt></b></dt>
<dd>
The part of the <tt class="member">tagName</tt> preceding the colon if there is one,
else the empty string.  The value is a string, or <code>None</code>
</dl>

<p>
<dl><dt><b><tt id='l2h-1785' xml:id='l2h-1785' class="member">namespaceURI</tt></b></dt>
<dd>
The namespace associated with the element name.  This will be a
string or <code>None</code>.  This is a read-only attribute.
</dl>

<p>
<dl><dt><b><tt id='l2h-1786' xml:id='l2h-1786' class="member">nodeName</tt></b></dt>
<dd>
This has a different meaning for each node type; see the DOM
specification for details.  You can always get the information you
would get here from another property such as the <tt class="member">tagName</tt>
property for elements or the <tt class="member">name</tt> property for attributes.
For all node types, the value of this attribute will be either a
string or <code>None</code>.  This is a read-only attribute.
</dl>

<p>
<dl><dt><b><tt id='l2h-1787' xml:id='l2h-1787' class="member">nodeValue</tt></b></dt>
<dd>
This has a different meaning for each node type; see the DOM
specification for details.  The situation is similar to that with
<tt class="member">nodeName</tt>.  The value is a string or <code>None</code>.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1788' xml:id='l2h-1788' class="method">hasAttributes</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Returns true if the node has any attributes.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1789' xml:id='l2h-1789' class="method">hasChildNodes</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Returns true if the node has any child nodes.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1790' xml:id='l2h-1790' class="method">isSameNode</tt></b>(</nobr></td>
  <td><var>other</var>)</td></tr></table></dt>
<dd>
Returns true if <var>other</var> refers to the same node as this node.
This is especially useful for DOM implementations which use any sort
of proxy architecture (because more than one object can refer to the
same node).

<p>
<div class="note"><b class="label">Note:</b>
This is based on a proposed DOM Level&nbsp;3 API which is still in the
  ``working draft'' stage, but this particular interface appears
  uncontroversial.  Changes from the W3C will not necessarily affect
  this method in the Python DOM interface (though any new W3C API for
  this would also be supported).
</div>
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1791' xml:id='l2h-1791' class="method">appendChild</tt></b>(</nobr></td>
  <td><var>newChild</var>)</td></tr></table></dt>
<dd>
Add a new child node to this node at the end of the list of children,
returning <var>newChild</var>.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1792' xml:id='l2h-1792' class="method">insertBefore</tt></b>(</nobr></td>
  <td><var>newChild, refChild</var>)</td></tr></table></dt>
<dd>
Insert a new child node before an existing child.  It must be the case
that <var>refChild</var> is a child of this node; if not,
<tt class="exception">ValueError</tt> is raised.  <var>newChild</var> is returned. If
<var>refChild</var> is <code>None</code>, it inserts <var>newChild</var> at the end of
the children's list.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1793' xml:id='l2h-1793' class="method">removeChild</tt></b>(</nobr></td>
  <td><var>oldChild</var>)</td></tr></table></dt>
<dd>
Remove a child node.  <var>oldChild</var> must be a child of this node; if
not, <tt class="exception">ValueError</tt> is raised.  <var>oldChild</var> is returned on
success.  If <var>oldChild</var> will not be used further, its
<tt class="method">unlink()</tt> method should be called.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1794' xml:id='l2h-1794' class="method">replaceChild</tt></b>(</nobr></td>
  <td><var>newChild, oldChild</var>)</td></tr></table></dt>
<dd>
Replace an existing node with a new node. It must be the case that 
<var>oldChild</var> is a child of this node; if not,
<tt class="exception">ValueError</tt> is raised.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1795' xml:id='l2h-1795' class="method">normalize</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Join adjacent text nodes so that all stretches of text are stored as
single <tt class="class">Text</tt> instances.  This simplifies processing text from a
DOM tree for many applications.

<span class="versionnote">New in version 2.1.</span>

</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1796' xml:id='l2h-1796' class="method">cloneNode</tt></b>(</nobr></td>
  <td><var>deep</var>)</td></tr></table></dt>
<dd>
Clone this node.  Setting <var>deep</var> means to clone all child nodes as
well.  This returns the clone.
</dl>

<p>

<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="8.6.2.1 domimplementation Objects"
  href="dom-implementation-objects.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="8.6.2 objects in the"
  href="node217.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="8.6.2.3 nodelist Objects"
  href="dom-nodelist-objects.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="dom-implementation-objects.html">8.6.2.1 DOMImplementation Objects</a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="node217.html">8.6.2 Objects in the</a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="dom-nodelist-objects.html">8.6.2.3 NodeList Objects</a>
</div>
</div>
<hr />
<span class="release-info">Release 2.5.1, documentation updated on 18th April, 2007.</span>
</div>
<!--End of Navigation Panel-->
<address>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</address>
</body>
</html>
